
#define pll_set_rf(x, n) pll_set_freq(x, n, 0x1)
#define pll_set_if(x, n) pll_set_freq(x, n, 0x4)
#define pll_set(w, x, n) pll_set_freq(x, n, (w)==VCO_HI?1:4)

#define PLLCLK_DDR DDRD
#define PLLCLK_PORT PORTD
#define PLLCLK PD5

#define PLLDATA_DDR DDRD
#define PLLDATA_PORT PORTD
#define PLLDATA PD6

#define PLLLE_DDR DDRB
#define PLLLE_PORT PORTB
#define PLLLE PB0

#define PLL_RFIN_DDR DDRC
#define PLL_IFIN_DDR DDRC
#define PLL_RFIN PC0
#define PLL_IFIN PC5
#define PLL_RFIN_PIN PINC
#define PLL_IFIN_PIN PINC
#define PLL_RFIN_PORT PORTC
#define PLL_IFIN_PORT PORTC

void turn_on_vco(uint8_t which);

void set_dcoff(uint8_t which, uint8_t val);

uint8_t get_dcoff(uint8_t which);

uint8_t read_lock_pin_digital(uint8_t which);
uint16_t read_lock_pin_analog(uint8_t which);

void pll_tx(uint32_t data, uint8_t addr) ;
void pll_init(void) ;
void pll_set_rcounter(uint16_t rcounter);
void pll_set_freq(uint16_t rf_freq, uint8_t prescaler, uint8_t reg);
uint8_t tune_vco(uint8_t which, uint16_t freq);
uint8_t tune_vco_band(uint8_t which, uint16_t min, uint16_t max);
